var express = require('express');
var router = express.Router();

function test(req, res, next) {
  const time = new Date();
  console.log(`[${time.toLocaleString()}] ${req.method} ${req.url}`);
  next();
}

/* GET home page. */
router.get('/', test, function(req, res, next) {
  // res.render('index', { title: 'Index get'});
  res.send("response")
});

router.post('/', function(req, res, next) {
  console.log("收到的请求体:", req.body);
  res.status(201).send();
});

router.put("/:id", (req, res) => {
  console.log("收到请求参数，id为", req.params.id);
  console.log("收到的请求体：", req.body);
  res.send();
})

module.exports = router;
